<template>
    <div style="max-width: 900px; margin: 0 auto;">
        <h2 style="text-align: center; margin: 30px 0;">入院评估单</h2>
        <div style="display: flex; justify-content: space-between; margin-bottom: jknk0px; font-size: 16px;">
            <div>姓名：{{ route.query.name }}</div>
            <div>性别：{{ Number(route.query.sex) == 1 ? '男' : '女' }}</div>
            <div>年龄：{{ route.query.age }}</div>
            <div>科别：{{ route.query.officeCode }}</div>
            <div>床号：{{ route.query.bedCode }}</div>
        </div>
    </div>
    <div>
        <div style="display: flex; justify-content: flex-end; margin-bottom: 10px;">
            <el-button type="primary" @click="ExportExcel">导出</el-button>
        </div>
        <el-table :data="tableData" border style="width: 100%">
            <el-table-column type="index" label="序号" width="55px" />
            <el-table-column prop="inType" label="入院类型" />
            <el-table-column prop="sense" label="意识状态" />
            <el-table-column prop="language" label="语言" />
            <el-table-column prop="activity" label="活动能力" />
            <el-table-column prop="vision" label="视力" width="200px" />
            <el-table-column prop="hearing" label="听力" width="200px" />
            <el-table-column prop="maxExcrete" label="大便" />
            <el-table-column prop="minExcrete" label="小便" />
            <el-table-column prop="signUrl" label="签名" width="200px">
                <template #default="scope">
                    <img :src="scope.row.signUrl" style="width: 200px; height: 50px;" />

                </template>
            </el-table-column>
        </el-table>
        <el-pagination v-model:current-page="page.pageIndex" v-model:page-size="page.pageSize"
            :page-sizes="[10, 20, 30, 40]" :background="true" layout="total, sizes, prev, pager, next, jumper"
            :total="page.totalCount" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
    </div>
</template>

<script lang="ts" setup>
import http from '@/api/http';
import { onMounted, reactive, ref, } from 'vue';
import { useRouter, useRoute } from 'vue-router';
const router = useRouter();
const route = useRoute();
onMounted(() => {
    show();
})

// 导出Excel
const ExportExcel = () => {
    location.href = 'http://localhost:9991/api/InAssessController/ExportExcel'
}

const page = reactive({
    pageIndex: 1,
    pageSize: 10,
    totalPage: 1,
    totalCount: 0
})

const show = () => {
    http.get('/api/InAssessController/ShowInAssess', {
        params: {
            pageIndex: page.pageIndex,
            pageSize: page.pageSize,
        }
    }).then((res) => {
        console.log(res)
        tableData.value = res.data.items
        page.totalCount = res.data.totalCount
        page.totalPage = res.data.totalPage
    });
}

const handleSizeChange = (val: number) => {
    page.pageSize = val
    show()
}
const handleCurrentChange = (val: number) => {
    page.pageIndex = val
    show()
}

const tableData = ref([])

</script>